<?php
	require("includes/basic.php");
	if(!isset($_SESSION['uid']) && $userType!='A')
	{
		header("location:authorise.php");
	}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
	<HEAD>
		
		<TITLE> :: <?php echo $appName?> :: </TITLE>
		<link rel='stylesheet' type='text/css' href='style/inner.css'>
		<script type='text/javascript' src='js/inner.js'></script>
		<script type='text/javascript' src='js/jquery-latest.js'></script>
		<script type='text/javascript'>
		$(document).ready(function()
		{
			$('#user_name').focusout(function()
			{
				var uname =  $('#user_name').val();
				var puname = $('#prevusername').val();
				if(uname== "")
				{
				  
				}				
				else
				{
					if(uname == puname)
					{					
					}
					else
					{
						var dataString = 'uname=' + uname;
						$.ajax
						({
							type: "POST",
							url: "checkuname.php",
							data: dataString,
							cache: false,
							success: function(html)
							{
								$("#error").html(html);
							} 
						});
					}
				
				}
				
			});
			
		});
		</script>
		<script>
			function checkSubmit()
			{
				var error = document.getElementById('error').innerHTML;
				if(error == "Already exists")
				{
					return false;
				}
			}
		</script>
		<!-- validation start -->
		<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css" media="screen" title="no title" charset="utf-8" />
		<link rel="stylesheet" href="css/template.css" type="text/css" media="screen" title="no title" charset="utf-8" />
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>
		<script src="js/jquery.validationEngine-en.js" type="text/javascript"></script>
		<script src="js/jquery.validationEngine.js" type="text/javascript"></script>


		<script>	
		$(document).ready(function() {

			
			$("#edit-customer").validationEngine()
		
			
		});
		
		
		function validate2fields(){
			var ext = $('#uploadedfile').val().split('.').pop().toLowerCase();
			var extnlen = ($('#uploadedfile').val()).length;
			
			if($.inArray(ext, ['gif','png','jpg','jpeg']) == -1 && extnlen > 0){
				return false;
			}else{
				return true;
			}
		}
	</script>
<!-- validation end -->

	</HEAD>

	<body unselectable="on" class="dialog"> 
		<?php $pageName="Administration View"; ?>
		<?php require("includes/header.php"); ?>

		<!-- devi : body content begins here -->
		<table class="dialog" cellpadding="0" cellspacing="0"><tr><td> 
		<table class="dialogbox" cellpadding="0" cellspacing="0"> 
		<tr><td> 
		<div class="dialoghead" unselectable="on">Edit Customer Wizard</div>
        <div class="dialogcontent" style="height: 450px; unselectable="on">
		<form id="edit-customer" name="edit-customer" action="edit-customer-process.php" method="post" enctype="multipart/form-data" onSubmit="return checkSubmit()" class="nomargin">
		

		<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%;">
		<tr><td style="vertical-align: top;">

		<div class="dialogspacer" unselectable="on">&nbsp;</div>
			<?php $buttonTitle = "Edit Customer"; ?>
			<?php $buttonSize = "200px"; ?>
			<?php require("greenHeaderButton.php"); ?>
		<div class="dialogspacer" unselectable="on">&nbsp;</div>

		<div class="dialogblockborder dialogblockborderheadline" unselectable="on"> 
		<div class="dialogblock" unselectable="on"> 
		<span class="dialogblockhead" unselectable="on">Security</span>
<?php	
if(isset($_SESSION['uid'])) {
$cid=$_REQUEST['custid'];	
$custdetails=mysql_query("select * from customer_master where customer_id=$cid");
$row=mysql_fetch_array($custdetails);
extract($row);
$custname=$row['customer'];
$cust_desc=$row['cust_desc'];
$uname=$row['user_name'];

$pass=base64_decode($row['password']);	
$usertypeid=$row['usertypeid'];

?>
		<input type="hidden" name="usertypeid" id="usertypeid" value="<?php echo $usertypeid;?>">
		<input type="hidden" name="prevusername" id='prevusername' value="<?php echo $uname;?>">
		<table border="0" cellpadding="2" cellspacing="0">
			<tr>
				<td>Customer User Name : </td>
				<td><input type="text" name="user_name" id="user_name" size="8" class="validate[required,custom[email]] text-input" style="width:150px;" value='<?php echo $uname;?>'></td>
				<td><img id="img1" name="img1" src="images/help.png" border="0" onmouseout="hideHelp(1);" onmouseover="showHelp(1);"></td>
				<td id='error'></td>
			</tr>
			<tr>
				<td>Password : </td>
				<td><input type="password" name="password" id="password" size="8" class="validate[required] text-input" style="width:150px;" value="<?php echo $pass;?>"></td>
				<td><img id="img2" name="img2" src="images/help.png" border="0" onmouseout="hideHelp(2);" onmouseover="showHelp(2);"></td>
				<td></td>
			</tr>
			
		</table>
		</div></div>

        

			</td></tr>
			
			<tr><td style="vertical-align: bottom;">


			<div class="dialogblockborder dialogblockborderheadline" unselectable="on"> 
			<div class="dialogblock" unselectable="on"> 
			<span class="dialogblockhead" unselectable="on">Edit Customer Details</span>

	
			<table border="0">
	
			<!-- <tr><td colspan="5" ><b>EDIT CUSTOMER</b></td></tr> -->
			<tr><td colspan='3'><input type="hidden" name="custid" value="<?php echo $cid; ?>"></td></tr>

			<?php $custcontactdetails=mysql_query("select * from customer_contact where customer_id='$usertypeid'");
			$row1=mysql_fetch_array($custcontactdetails);
			//extract($row1);
			$mobile=$row1['mobile'];
			$add=$row1['address'];
			$contactname=$row1['customer_name'];
			?>


    
			<tr>
				<td align="left">Customer Name : </td>
				<td align="left"><Input type="text" name="cust_name" id="cust_name" class="validate[required] text-input" value="<?php echo $custname;?>"/></td>
				<td><img id="img3" name="img3" src="images/help.png" border="0" onmouseout="hideHelp(3);" onmouseover="showHelp(3);"></td>
			</tr>
			<tr>
				<td align="left">Customer Contact Name : </td>
				<td align="left"><Input type="text" name="cust_contname" id="cust_contname" class="validate[required] text-input" value="<?php echo $contactname;?>"/></td>
				<td><img id="img3" name="img3" src="images/help.png" border="0" onmouseout="hideHelp(3);" onmouseover="showHelp(3);"></td>
			</tr>
			<tr>
				<td>Customer Description : </td>
				<td align="left"><textarea name="cust_desc" id="cust_desc" class="validate[required] text-input" rows="2" cols="60"><?php echo $cust_desc;?></textarea></td>
				<td><img id="img4" name="img4" src="images/help.png" border="0" onmouseout="hideHelp(4);" onmouseover="showHelp(4);"></td>
			</tr>			
	
			<tr>
				<td align="left">Mobile : </td>
				<td align="left"><Input type="text" name="mob" id="mob" class="validate[required,custom[onlyNumber]] text-input" value="<?php echo $mobile;?>"/></td>
				<td><img id="img5" name="img5" src="images/help.png" border="0" onmouseout="hideHelp(5);" onmouseover="showHelp(5);"></td>
			</tr>

			<tr>
				<td align="left">Address</td>
				<td align="left"><textarea name="add" id="add" class="validate[required] text-input" rows="2" cols="60" /><?php echo $add;?></textarea></td>
				<td><img id="img6" name="img6" src="images/help.png" border="0" onmouseout="hideHelp(6);" onmouseover="showHelp(6);"></td>
			</tr>
			<tr>
				<td>Upload New Customer Logo : </td>
				<td><INPUT TYPE="file" NAME="uploadedfile" id='uploadedfile' class="validate[funcCall[validate2fields]]"></td>
				<td><img id="img9" name="img9" src="images/help.png" border="0" onmouseout="hideHelp(9);" onmouseover="showHelp(9);"></td>
			</tr>

	</table>
  </div></div>


	<div class="dialogbuttons" unselectable="on">

		<input name="back" type="button" value="&#060;&#060; Back" class="dialogbutton" onclick="javascript:history.go(-1)">
		<input name="submit" type="submit" value="Save &#062;&#062;" class="dialogbutton">
		<input name="cancel" type="button" value="Cancel" class="dialogbutton" onclick="window.location.href='index.php';" style="margin-left: 50px;">
		
		</div>
		</td></tr></table>
</form>
</div>

		<div class="help" name="help1" id="help1" onmouseout="hideHelp(1);" onmouseover="showHelp(1);">
			Edit Customer User Name.The username required for the customer to login
		</div>


		<div class="help" name="help2" id="help2" onmouseout="hideHelp(2);" onmouseover="showHelp(2);">
			Edit Customer Password.The password required for the customer to login
		</div>

		<div class="help" name="help3" id="help3" onmouseout="hideHelp(3);" onmouseover="showHelp(3);">
			Edit Customer Name.
		</div>

		<div class="help" name="help4" id="help4" onmouseout="hideHelp(4);" onmouseover="showHelp(4);">
			Edit Customer Description.
		</div>

		<div class="help" name="help5" id="help5" onmouseout="hideHelp(5);" onmouseover="showHelp(5);">
			Edit Customer Mobile Number.
		</div>

		<div class="help" name="help6" id="help6" onmouseout="hideHelp(6);" onmouseover="showHelp(6);">
			Edit Customer Address.
		</div>
		
		<div class="help" name="help9" id="help9" onmouseout="hideHelp(9);" onmouseover="showHelp(9);">
			Upload new customer logo.
		</div>

		<!-- <div class="help" name="help7" id="help7" onmouseout="hideHelp(7);" onmouseover="showHelp(7);">
			Enter the postal address of the company
		</div> -->

		</td></tr></table> 
		</td></tr></table> 
		<p>&nbsp;</p> 

		<!-- devi : body content ends here -->
		<?php }?>
		<?php require("includes/footer.php"); ?>
	</BODY>
</HTML>
